package com.my.study.init.serverInit;

import com.my.study.enums.PayTypeEnum;
import com.my.study.init.dto.PaymentDTO;
import com.my.study.init.listener.DefaultPaymentListener;
import com.my.study.init.listener.PaymentListener;

public abstract class BasePaymentService implements PaymentService{

    protected PaymentListener paymentListener = new DefaultPaymentListener();

    public abstract PayTypeEnum getPayTypeEnum();

    public abstract boolean pay(PaymentDTO paymentDTO);

    public boolean setListener(PaymentListener paymentListener){
        this.paymentListener = paymentListener;
        return true;
    }

    public void onBefore(){
        if(paymentListener != null){
            paymentListener.before();
        }
    }

    public void onAfter(){
        if(paymentListener != null){
            paymentListener.after();
        }
    }

}
